<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NeuZephyr: D:/Users/Mgepahmge/Documents/C Program/NeuZephyr/include/NeuZephyr/EventPool.cuh File Reference</title>
<link rel="icon" href="NZ_logo2.png" type="image/x-icon" />
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="NZ_logo2.png"/></td>
  <td id="projectalign">
   <div id="projectname">NeuZephyr
   </div>
   <div id="projectbrief">Simple DL Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d522931ffa1371640980b621734a4381.html">Users</a></li><li class="navelem"><a class="el" href="dir_a7e6ee1ae3f772c9504a0b543f2027e2.html">Mgepahmge</a></li><li class="navelem"><a class="el" href="dir_e03f57e346cc4845a4c354a35630b169.html">Documents</a></li><li class="navelem"><a class="el" href="dir_231a0482af2b83c895f27ba7fe745141.html">C Program</a></li><li class="navelem"><a class="el" href="dir_0fa7fc3a0dfd304dbfc9dce9f6facfa2.html">NeuZephyr</a></li><li class="navelem"><a class="el" href="dir_e7295b03dab2e9cdf32139bd8ec2e607.html">include</a></li><li class="navelem"><a class="el" href="dir_657344ecc65cfc28732701509f8d8421.html">NeuZephyr</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#namespaces">Namespaces</a>  </div>
  <div class="headertitle"><div class="title">EventPool.cuh File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Definition of the EventPool class for managing CUDA events in multi-stream environments.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;map&gt;</code><br />
<code>#include &lt;mutex&gt;</code><br />
<code>#include &lt;queue&gt;</code><br />
<code>#include &lt;unordered_map&gt;</code><br />
<code>#include &lt;unordered_set&gt;</code><br />
<code>#include &lt;vector&gt;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for EventPool.cuh:</div>
<div class="dyncontent">
<div class="center"><img src="_event_pool_8cuh__incl.png" border="0" usemap="#a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_event_pool_8cuh" alt=""/></div>
<map name="a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_event_pool_8cuh" id="a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_event_pool_8cuh">
<area shape="rect" title="Definition of the EventPool class for managing CUDA events in multi&#45;stream environments." alt="" coords="138,5,340,80"/>
<area shape="rect" title=" " alt="" coords="5,128,52,155"/>
<area shape="poly" title=" " alt="" coords="160,83,67,125,65,121,158,78"/>
<area shape="rect" title=" " alt="" coords="76,128,133,155"/>
<area shape="poly" title=" " alt="" coords="189,83,136,121,133,117,186,78"/>
<area shape="rect" title=" " alt="" coords="158,128,214,155"/>
<area shape="poly" title=" " alt="" coords="221,82,203,115,198,113,217,79"/>
<area shape="rect" title=" " alt="" coords="239,128,349,155"/>
<area shape="poly" title=" " alt="" coords="262,79,281,113,277,115,258,82"/>
<area shape="rect" title=" " alt="" coords="373,128,476,155"/>
<area shape="poly" title=" " alt="" coords="311,78,388,118,386,123,309,83"/>
<area shape="rect" title=" " alt="" coords="500,128,557,155"/>
<area shape="poly" title=" " alt="" coords="342,75,486,123,484,128,340,80"/>
</map>
</div>
</div><div class="textblock"><div class="dynheader">
This graph shows which files directly or indirectly include this file:</div>
<div class="dyncontent">
<div class="center"><img src="_event_pool_8cuh__dep__incl.png" border="0" usemap="#a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_event_pool_8cuhdep" alt=""/></div>
<map name="a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_event_pool_8cuhdep" id="a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_event_pool_8cuhdep">
<area shape="rect" title="Definition of the EventPool class for managing CUDA events in multi&#45;stream environments." alt="" coords="591,5,793,80"/>
<area shape="rect" href="_stream_manager_8cuh_source.html" title=" " alt="" coords="591,128,793,203"/>
<area shape="poly" title=" " alt="" coords="695,96,695,128,689,128,689,96"/>
<area shape="rect" href="_compute_graph_8cu_source.html" title=" " alt="" coords="5,251,227,309"/>
<area shape="poly" title=" " alt="" coords="576,190,239,253,227,256,226,251,238,248,575,184"/>
<area shape="rect" href="_mapped_tensor_8cu_source.html" title=" " alt="" coords="251,251,469,309"/>
<area shape="poly" title=" " alt="" coords="577,208,445,253,444,248,575,203"/>
<area shape="rect" href="_nodes_8cu_source.html" title=" " alt="" coords="493,251,664,309"/>
<area shape="poly" title=" " alt="" coords="647,215,609,252,606,248,643,212"/>
<area shape="rect" href="_operation_kernels_8cu_source.html" title=" " alt="" coords="689,251,922,309"/>
<area shape="poly" title=" " alt="" coords="741,212,778,248,775,252,737,215"/>
<area shape="rect" href="_optimizer_8cu_source.html" title=" " alt="" coords="947,251,1136,309"/>
<area shape="poly" title=" " alt="" coords="809,201,953,248,951,253,807,206"/>
<area shape="rect" href="_tensor_8cu_source.html" title=" " alt="" coords="1160,251,1333,309"/>
<area shape="poly" title=" " alt="" coords="809,182,971,211,1149,248,1161,251,1160,256,1147,253,970,216,808,188"/>
</map>
</div>
</div>
<p><a href="_event_pool_8cuh_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classnz_1_1cu_strm_1_1_event_pool.html">nz::cuStrm::EventPool</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Internal event management system for CUDA stream synchronization (Part of <a class="el" href="classnz_1_1cu_strm_1_1_stream_manager.html" title="Centralized CUDA stream and resource management system with automatic dependency tracking.">StreamManager</a>)  <a href="classnz_1_1cu_strm_1_1_event_pool.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
Namespaces</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacenz_1_1cu_strm.html">nz::cuStrm</a></td></tr>
<tr class="memdesc:namespacenz_1_1cu_strm"><td class="mdescLeft">&#160;</td><td class="mdescRight">Provides core components for CUDA stream and event lifecycle management in GPU computing environments. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Definition of the EventPool class for managing CUDA events in multi-stream environments. </p>
<p>This file provides the declaration of the <code>EventPool</code> class, which is designed to efficiently manage CUDA event allocation, recycling, and synchronization across multiple streams. It supports tracking events associated with specific data pointers for advanced synchronization use cases in GPU computing.</p>
<p>The <code>EventPool</code> class encapsulates the following key features:</p><ul>
<li><b>Event Pooling</b>: Pre-allocates a configurable number of CUDA events (<code>cudaEvent_t</code>) and dynamically expands the pool when demand exceeds supply, minimizing runtime overhead.</li>
<li><b>Event-Data Association</b>: Tracks relationships between CUDA events and user data pointers, enabling synchronization based on data completion status.</li>
<li><b>Thread Safety</b>: Utilizes mutexes and condition variables to ensure safe concurrent access across threads.</li>
<li><b>Automatic Recycling</b>: Automatically reclaims completed events via CUDA stream callbacks, reducing manual resource management.</li>
<li><b>Efficient Queries</b>: Provides fast lookups for events associated with specific data through hash-based mappings.</li>
</ul>
<p>This class is part of the <code><a class="el" href="namespacenz_1_1cu_strm.html" title="Provides core components for CUDA stream and event lifecycle management in GPU computing environments...">nz::cuStrm</a></code> namespace and is optimized for scenarios requiring fine-grained synchronization between GPU operations and host-side data management.</p>
<dl class="section note"><dt>Note</dt><dd><ol type="1">
<li>All events are created with <code>cudaEventDisableTiming</code> for minimal overhead.</li>
<li>Users must ensure proper destruction of the pool to avoid CUDA resource leaks.</li>
<li>The <code>syncData</code> method blocks until all events associated with a data pointer complete.</li>
</ol>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>This class is an internal component of the <a class="el" href="classnz_1_1cu_strm_1_1_stream_manager.html" title="Centralized CUDA stream and resource management system with automatic dependency tracking.">nz::cuStrm::StreamManager</a> system. It should not be instantiated or accessed directly in most use cases. Event management should be handled exclusively through StreamManager's interfaces to maintain proper synchronization and resource lifecycle management.</dd></dl>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2024/11/29 </dd></dl>

<p class="definition">Definition in file <a class="el" href="_event_pool_8cuh_source.html">EventPool.cuh</a>.</p>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
